<template>
	<view>
		<!-- <u--image :src="src" width="100vw" height="100vh"></u--image> -->
		<view class="app-logo">
			<u--image :src="src" width="72px" height="72px"></u--image>
			<view class="app-title">花儿朵朵</view>	
		</view>
	</view>
</template>

<script>
	import {loginByCode, getSysSettings, parkIntroduce, ticketCategory, releaseNotice} from '@/api/home.js'
	import {getAdoptSetUp} from '@/api/foster.js'
	import {goodsCategory} from '@/api/shop.js'
	import {mapActions} from 'vuex';
	import Vue from 'vue';
	export default {
		data() {
			return {
				src: 'https://zhengxin-pub.cdn.bcebos.com/logopic/6d857a79d0f2d08b2dbf037120add682_fullsize.jpg?x-bce-process=image/resize,m_lfit,w_200'
				// src : 'https://doublelonghu.oss-cn-beijing.aliyuncs.com//temp/791a77ca3820a9959a88eb911c4d38bc_1665278114683.jpeg'
			}
		},
		onLoad({id}) {
			const that = this;
			// uni.getLocation({
			// 	type: 'wgs84',
			// 	success: function(res) {
			// 		const {latitude, longitude} = res;
			// 		that.setLatLng({latLng: latitude + ',' + longitude});
			// 	}
			// });
			this.setActiveTabbar({activeTabbar: 'home'});
			// 获取系统配置
			getSysSettings().then(res => {
				const {result} = res;
				// 主题色
				Vue.prototype.appPrimaryColor = result.theme.themeColor || '#2AAF60';
				this.setAppInfo({appInfo: result});
				uni.login({
					success(e) {
						const {code} = e;
						loginByCode({code}).then(res => {
							const {code, result, success} = res;
							if(code === 200 && success) {
								const {userInfo, token} = result;
								that.setUserInfo({
									userInfo,
									token
								});
							} else {
								uni.clearStorageSync();
							}
							if(id) {
								uni.redirectTo({
									url: `/pages/foster/fosterDetail?id=${id}&share=1`
								})
							} else {
								uni.redirectTo({
									url: '/pages/index/index'
								});
							}
						})
					}
				})
			})
			// 获取认养页面配置
			getAdoptSetUp().then(res => {
				const {result} = res;
				this.setAdoptSetUp({adoptSetUp: result});
			})
			// 获取商品分类
			goodsCategory().then(res => {
				const {result} = res;
				this.setGoodsCategory({goodsCategory: result});
			})
			// 获取景区分类
			ticketCategory().then(res => {
				const {result} = res;
				this.setTicketCategory({ticketCategory: result});
			})
			// 获取发现景区
			parkIntroduce().then(res => {
				const {result} = res;
				this.setParkIntroduce({parkIntroduce: result});
			})
			// 首页通知
			releaseNotice().then(res => {
				const {result} = res;
				this.setReleaseNotice({releaseNotice: result});
			})
		},
		methods: {
			...mapActions(['setAppInfo', 'setUserInfo', 'setAdoptSetUp', 'setActiveTabbar', 'setLatLng', 'setGoodsCategory', 'setParkIntroduce', 'setTicketCategory', 'setReleaseNotice']),
		}
	}
</script>

<style lang="scss" scoped>
	.app-logo {
		position: fixed;
		bottom: 160rpx;
		left: 50%;
		transform: translateX(-50%);
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.app-title {
			padding-top: 12rpx;
			color: #333;
			font-weight: bold;
			letter-spacing: 2rpx;
		}
	}
</style>